<?php 
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\captcha\Captcha;
?>
<!DOCTYPE html>
<html lang="en" class="no-js">

    <head>

        <meta charset="utf-8">
        <title>Fullscreen Login</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="">
        <meta name="author" content="">

        <!-- CSS -->
        <link rel='stylesheet' href='http://fonts.googleapis.com/css?family=PT+Sans:400,700'>
        <link rel="stylesheet" href="assets/css/reset.css">
        <link rel="stylesheet" href="assets/css/supersized.css">
        <link rel="stylesheet" href="assets/css/style.css">

        <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
        <!--[if lt IE 9]>
            <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->

    </head>

    <body>

        <div class="page-container">
            <h1>登录</h1>
            <?php $form = ActiveForm::begin(); ?>

            <?= $form->field($model, 'name')->textInput(['placeholder'=>'账号']) ?>
            <?= $form->field($model, 'pwd')->passwordInput(['placeholder'=>'密码'])?>

            <div class="form-group">
                <?= Html::Button('登录', ['class' => 'btn btn-primary']) ?>
            </div>
            <?php ActiveForm::end(); ?>

        </div>

        <!-- Javascript -->
        <script src="assets/js/jquery-1.8.2.min.js"></script>
        <script src="assets/js/supersized.3.2.7.min.js"></script>
        <script src="assets/js/supersized-init.js"></script>
        <script src="assets/js/scripts.js"></script>

    </body>

</html>

<script>
    $(function()
    {
        $('input').blur(function(){
            if($(this).val()=='')
            {
                $(this).attr('placeholder','不能为空')
            }
        })
        $('.btn').click(function(){
            var name = $("input[name='User[name]']").val();
            var pwd = $("input[name='User[pwd]']").val();
            var _csrf = $("input[name='_csrf']").val();
            if(name==''){
                $("input[name='User[name]']").attr('placeholder','不能为空')
            }
            if(pwd=='')
            {
                $("input[name='User[pwd]']").attr('placeholder','不能为空')
                return;
            }
            $.ajax({
                type:'post',
                url:'?w=login/ajax',
                data:{_csrf:_csrf,name:name,pwd:pwd},
                dataType:"json",
                success:function(data){
                    if(data.error)
                    {
                        alert(data.msg)
                        location.href='?w=admin%2Findex';
                    }else{
                        alert(data.msg)
                    }
                }
            })

        });
    })
</script>